package com.blockmeta.bbs.immodule.adapter;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import android.widget.Button;

import com.blockmeta.bbs.baselibrary.base.adapter.BaseAdapter;
import com.blockmeta.bbs.baselibrary.utils.LoadPicUtil;
import com.blockmeta.bbs.businesslibrary.util.AccountHelper;
import com.blockmeta.bbs.businesslibrary.widget.CircleImageView;
import com.blockmeta.bbs.immodule.R;
import com.blockmeta.bbs.immodule.bean.databean.UserBean;
import com.blockmeta.bbs.immodule.utils.IMUtils;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;


public class RecommandUserAdapter extends BaseAdapter<UserBean, BaseViewHolder> {

    public RecommandUserAdapter(int layoutResId, @Nullable List<UserBean> data) {
        super(layoutResId, data);
    }

    @Override
    public void bindToRecyclerView(RecyclerView recyclerView) {
        super.bindToRecyclerView(recyclerView);
    }

    @Override
    protected void convert(BaseViewHolder helper, final UserBean item) {
        CircleImageView avatar = helper.getView(R.id.contacts_avatar);
        LoadPicUtil.loadWithPicasso(avatar, item.getLogo());

        helper.setText(R.id.contacts_name,item.getName());
        helper.addOnClickListener(R.id.btn_addfriend);
        helper.setGone(R.id.btn_addfriend,!(AccountHelper.getUidInt()==item.getId()));

        Button addFriend = helper.getView(R.id.btn_addfriend);
        addFriend.setEnabled(!item.isHasBeenSentFriendRequest()&&!item.isFriend());
        addFriend.setText(item.isHasBeenSentFriendRequest()?"已发送":item.isFriend()?"已添加":"+ 好友");
        if (item.getGroupId()==-1){
            helper.setGone(R.id.group_grade,false);
        }else {
            helper.setGone(R.id.group_grade,true);
            helper.setText(R.id.contacts_grade, IMUtils.UserLevel.getUserLevel(item.getGroupId()).getValue());
        }
        helper.setText(R.id.person_resume, item.getIndividualResume());

//        helper.setText(R.id.contacts_registration_time,item.getRegistrationTime());

    }



}
